package cn.com.fattiger.framework.cms.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.jdbc.core.JdbcTemplate;


@Configuration
public class DatabaseConfiguration{
	
	@Autowired
	PrivateDataSource privateDataSource;
	
	@Bean
	public JdbcTemplate jdbcTemplate(){
		return new JdbcTemplate(privateDataSource);
	}

	@Bean
	RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory connectionFactory) {
		RedisTemplate<String,Object>  template = new RedisTemplate<String,Object>();
		template.setConnectionFactory(connectionFactory);
		
		template.setKeySerializer(new StringRedisSerializer());
		template.setDefaultSerializer(new StringRedisSerializer());
		return template;
	}

}
